#include "../logs/shwLog.h"

void loggerTest(const std::string& name)
{

    shw::Logger::ptr lp = shw::getLogger(name);
    assert(lp.get());
    FATAL_LOG("------------example--------------------");
    lp->Debug("%s", "logger->debug");
    lp->Info("%s",  "logger->info");
    lp->Warn("%s",  "logger->warn");
    lp->Error("%s", "logger->error");
    lp->Fatal("%s", "logger->fatal");
    DEBUG_LOG("%s", "LOG_DEBUG");
    INFO_LOG("%s",  "LOG_INFO");
    WARN_LOG("%s",  "LOG_WARN");
    ERROR_LOG("%s", "LOG_ERROR");
    FATAL_LOG("%s", "LOG_FATAL");
    FATAL_LOG("---------------------------------------");

    std::string log_msg = "hello world-";
    size_t fsize = 0;
    size_t count = 0;
    while (count < 1000000)
    {
        std::string msg = log_msg + std::to_string(count++);
        lp->Error("%s", msg.c_str());
    }
}

void functional_test() 
{
    shw::GlobalLoggerBuilder::ptr lbp(new shw::GlobalLoggerBuilder());
    lbp->Namebuilder("all_sink_logger");
    lbp->Formatbuilder("[%d][%c][%f:%l][%p] %m%n");
    lbp->Levelbuilder(shw::level::value::DEBUG);
    lbp->Sinkbuilder<shw::StoutSink>();
    lbp->Sinkbuilder<shw::FileSink>("./test_logs/sync.log");
    lbp->Sinkbuilder<shw::RollBysizeSink>("./test_logs/roll-", 10 * 1024 * 1024);
    lbp->LoggerTypebuilder(shw::LoggerType::LOGGER_ASYNC);
    lbp->Builder(); 
    loggerTest("all_sink_logger");
}

int main()
{
    functional_test();
    return 0;
}